package com.rush.manageepac.service.impl;

import com.rush.manageepac.dao.Information01Dao;
import com.rush.manageepac.entity.Information01;
import com.rush.manageepac.service.intf.Information01Service;
import com.rush.manageepac.util.StringUtil;
import com.rush.manageepac.vo.PageBean;
import com.rush.manageepac.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @outher zhy
 * 2022-08-30
 */
@Service
public class Information01ServiceImpl implements Information01Service {
    @Autowired
    private Information01Dao dao;
    @Override
    public R save(Information01 information01) {

        if (dao.save(information01)>0){
            return R.ok();
        }else {
            return R.fail();
        }
    }

    @Override
    public R delete(int id) {

        if (dao.delete(id)>0){
            return R.ok();
        }else {
            return R.fail();
        }
    }

    @Override
    public R update(Information01 information01) {
        if (dao.update(information01)>0){
            return R.ok();
        }else {
            return R.fail();
        }
    }

    @Override
    public PageBean selectPage(String name, int page, int limit) {
        if (StringUtil.isNotEmpty(name)){
            name="%"+name+"%";
        }
        int start=(page-1)*limit;
        return PageBean.ok(dao.selectCount(name),dao.selectPage(name,start,limit));
    }
}
